package com.contract.serlvet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.contract.Thread.Listener;
import com.contract.Thread.ThreadContract;

public class StartSerlvet extends HttpServlet {


	public StartSerlvet() {
		super();
	}


	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {


	}

	public void init() throws ServletException {
		
		System.err.println("开始");
		String times=this.getInitParameter("times");   

        long time = Long.parseLong(times);
		System.err.println("shijian=="+time);
		ThreadContract t1 = new ThreadContract("获取合约信息",time); 
		
		 Listener listener = new Listener();
		 t1.addObserver(listener);
		
		
		Thread thread = new Thread(t1); 
		thread.start();

		
	}

}
